package controller;

import business.datacenter.CreditPubReportGuaranteeInfoService;
import business.other.PubReportGuaranteeInfoService;
import datacenter.domain.CreditPubReportGuaranteeInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import other.domain.PubReportGuaranteeInfo;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by SunZZ on 2016/6/22.
 */
@Controller
public class CreditController {
    @Resource(name = "CGuaranteeService")
    private CreditPubReportGuaranteeInfoService creditPubReportGuaranteeInfoService;

    @Resource(name = "guaranteeService")
    private PubReportGuaranteeInfoService pubReportGuaranteeInfoService;

    @RequestMapping(value = "Guarantee.htm")
    public String saveGuarantee()
    {
        List<CreditPubReportGuaranteeInfo> data = new ArrayList<>();
        System.out.println("Guarantee start");
        for (PubReportGuaranteeInfo pubReportGuaranteeInfo : pubReportGuaranteeInfoService.getPubReportGuaranteeInfo()){
            CreditPubReportGuaranteeInfo info = new CreditPubReportGuaranteeInfo();
            info.setCorpid(pubReportGuaranteeInfo.getCorpid());
            info.setGuar_creditor(pubReportGuaranteeInfo.getGuarCreditor());
            info.setGuar_name(pubReportGuaranteeInfo.getGuarName());
            info.setGuar_credit_type(pubReportGuaranteeInfo.getGuarCreditType());
            info.setGuar_credit_amount(pubReportGuaranteeInfo.getGuarCreditAmount());
            info.setGuar_date_start(pubReportGuaranteeInfo.getGuarDateStart());
            info.setGuar_date_end(pubReportGuaranteeInfo.getGuarDateEnd());
            info.setGuar_period(pubReportGuaranteeInfo.getGuarPeriod());
            info.setGuar_type(pubReportGuaranteeInfo.getGuarType());
            info.setGuar_range(pubReportGuaranteeInfo.getGuarRange());
            data.add(info);
        }
        creditPubReportGuaranteeInfoService.saveCreditPubReportGuaranteeInfo(data);
        System.out.println("Guarantee");
        return "test";
    }

}
